import axios from 'axios'
import { getToken } from './storage'

// 创建axios实例
const service = axios.create({
  baseURL: '/api', // api 的 base_url
  timeout: 5000    // 请求超时时间
})

// request拦截器
service.interceptors.request.use(
  config => {
    config.headers['token'] = getToken();
    return config
  },
  error => {
    // Do something with request error
    console.log(error) // for debug
    Promise.reject(error)
  }
)

export default service
